package com.gulimall.product.dao;

import com.gulimall.product.entity.AttrAttrgroupRelationEntity;
import com.gulimall.product.entity.AttrEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;

/**
 * 商品属性
 * 
 * @author Rookie-886
 * @email ${email}
 * @date 2021-03-14 16:30:53
 */
@Mapper
public interface AttrDao extends BaseMapper<AttrEntity> {

    @Select("select attr_id,attr_name,search_type,icon,value_select,attr_type,enable,catelog_id,show_desc from pms_attr " +
            "where attr_id in (select attr_id from pms_attr_attrgroup_relation where attr_group_id = #{attrGroupId})")
    List<AttrEntity> selectAttrListByGroupId(Long attrGroupId);

    @Select("<script>select attr_id from pms_attr where attr_id in <foreach collection='collection' item='i' open='(' close=')' separator=','>#{i}</foreach> and" +
            " search_type = 1 </script>")
    List<Long> selectSearchIdByIdSet(Set<Long> attrIdSet);
}
